<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基本设置</title>

  <link rel="stylesheet" type="text/css" href="/system/css/right.css">
  <script type="text/javascript" src="/system/js/jquery.js"></script>
  <script type="text/javascript" src="/system/js/system.js"></script>
  <script type="text/javascript" src="/system/js/admin.js"></script>
</head>
<body style="overflow: auto;">
	<div class="basic bor">
			<div class="title fl">当前位置：加盟商管理 > {$detail['id']?'编辑加盟商':'新增加盟商'} </div>
			<div class="basic_r fr"><a href="">基本信息</a></div>
	</div>
<div class="notice">
<div class="n_title">
<!-- <span class="fl">添加会员</span>
 -->
</div>
<div class="ncontent">
<form action="{:url('User/shop_edit')}" method="post" enctype="multipart/form-data" >
<div class="setting">
    <input type ="hidden" name ="id" value = "{$detail['id']??''}">
	<ul>

		<li>
			<dd class="setting_t fl"><span>*</span>名称 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="name" value="{$detail.name??''}">
				<!-- <span>产品名称不能为空</span> -->
			</dd>
		</li>
        <li>
			<dd class="setting_t fl"><span>*</span>电话号码 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="phone" value="{$detail.phone??''}">
				<!-- <span>产品名称不能为空</span> -->
			</dd>
		</li>
		<li>
			<dd class="setting_t fl"><span>*</span>主账号 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="username" value="{$detail.username??''}" >
				<!-- <span>不可修改</span> -->
			</dd>
		</li>
 		<div class="clear"></div>

		<li>
			<dd class="setting_t fl"><span>*</span>地址 ：</dd>
			<dd class="setting_p fl">
				省份:
				<select  name="province" id="J_province" >
					{volist name ='province_list' id = "li"}
					  {if isset($detail['province'])}
					   {if $detail['province'] == $li['areaname']}
						<option value="{$li.areaname}" data-id =""  >{$li.areaname}</option>
						{/if}
					  {else /}
                        <option value="{$li.areaname}" data-id ="{$li.rowid}" >{$li.areaname}</option>
	                  {/if}
                   {/volist}
				</select>城市:
				<select  name="city" id="J_city" >
					 {if isset($detail['city']) }
					  <option value="" >{$detail.city}</option>
					 {/if}
				</select>
				区:<select  name="district" id="J_cdistrict" >
					 {if isset($detail['district']) }
					  <option value="" >{$detail.district}</option>
					 {/if}
				</select>
			</dd>
	
		</li>
		<li>
			<dd class="setting_t fl"><span>*</span>详细地址 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="detail" value="{$detail.detail??''}" >
				<!-- <span>不可修改</span> -->
			</dd>
		</li>
		<li>
			<dd class="setting_t fl"><span>*</span>对公账号 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="business_card" value="{$detail.business_card??''}" >
				<!-- <span>不可修改</span> -->
			</dd>
		</li>

       <li>
			<dd class="setting_t fl"><span>*</span>营业执照照片 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="business_pic" id="J_dy_img0"  >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic0">
				{if isset($detail['business_pic'])}
				  <a  class='liLabel' onclick='delpic(0)' num_id = '0' title='点击图片即可删除对应的身份证正面图片'  >
					<img src='{$detail.business_pic??''}'  height='50px;' style='margin-left:10px;'>
					<input class='infile' name='business_pic' type='text' value='{$detail.business_pic??''}' >
				  </a>
				  {/if}
				</div>
				</dd>
		   </li>
           <br/ >
		<li>
			<dd class="setting_t fl"><span>*</span>店铺封面照片 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="shop_pic" id="J_dy_img1"  >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic1">
				{if isset($detail['shop_pic'])}
				  <a  class='liLabel' onclick='delpic(1)' num_id = '1' title='点击图片即可删除对应的身份证正面图片'  >
					<img src='{$detail.shop_pic??''}'  height='50px;' style='margin-left:10px;'>
					<input class='infile' name='shop_pic' type='text' value='{$detail.shop_pic??''}' >
				  </a>
				  {/if}
				</div>
				</dd>
		   </li>
           <br/ >

        <li>
			<dd class="setting_t fl"><span>*</span>身份证号码 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="identify" value="{$detail.identify??''}" >
				<!-- <span>不可修改</span> -->
			</dd>
		</li>
		<li>
			<dd class="setting_t fl"><span>*</span>法人身份证正面 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="pic2" id="J_dy_img2"  >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic2">
					{if isset($detail['identify_picp'])}
				  <a  class='liLabel' onclick='delpic(2)' num_id = '2' title='点击图片即可删除对应的身份证正面图片'  >
					<img src="{$detail.identify_picp??''}"  height='50px;' style='margin-left:10px;'>
					<input class='infile' name="identify_picp" type='text' value='{$detail.identify_picp??''}' >
				  </a>
				  {/if}
				</div>
				</dd>
		   </li>
           <br/ >
            <li>
			<dd class="setting_t fl"><span>*</span>法人身份证背面 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="pic3" id="J_dy_img3" >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic3">
					{if isset($detail['identify_picb'])}
				 <a class='liLabel' onclick='delpic(3)' num_id = '3' title='点击图片即可删除对应的身份证正面图片'  >
					<img src='{$detail.identify_picb??''}'  height='50px;' style='margin-left:10px;'>
					<input class='infile' name='identify_picb' type='text' value='{$detail.identify_picb??''}' >
				  </a>
				  {/if}
				</div>
				</dd>
		    </li>

		<li>
			<dd class="setting_t fl"><span>*</span>加入金额 ：</dd>
			<dd class="setting_p fl"><input class="seinp" type="text" name="join_money" value="{$detail.join_money??''}" >
				<!-- <span>不可修改</span> -->
			</dd>
		</li>


		<li>
			<dd class="setting_t fl"> &nbsp;</dd>
			<dd class="setting_p fl">

			<input  type="hidden" name="store_id" value="1">
			<input class="submit" type="submit" value="保存">

			</dd>
		</li>
	</ul>


</div>
</form>
</div>
</div>
</script>

<script type="text/javascript">

$(function(){
	  	//上传图片
	$("#J_dy_img0").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="business_pic";
		upload(formData,0,name);
	});

	 	//上传图片
	$("#J_dy_img1").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="shop_pic";
		upload(formData,1,name);
	});
	//上传图片
	$("#J_dy_img2").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="identify_picp";
		upload(formData,2,name);
	});

	//上传图片
	$("#J_dy_img3").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="identify_picb";
		upload(formData,3,name);
	});

	 var rowsid = $("#J_province option:selected").attr("data-id");

	 console.log(rowsid);
	 if(rowsid != null){
	  getArea("060LVB","J_city")
	 }

    //获取城市列表
	$("#J_province").change(function(){
       var rowid = $("#J_province option:selected").attr("data-id");
       getArea(rowid,"J_city")
	});

	$("#J_city").change(function(){
       var rowid = $("#J_city option:selected").attr("data-id");
       getArea(rowid,"J_cdistrict");
	});

});



	function getArea(rowid,id){
		var data = {"rowid":rowid};
		$("#"+id).html("");
		$.ajax({
		url:"{:url('User/getCityList')}",
		type:'POST',
		data:{"rowid":rowid},
		dataType:'json',
		success:function(res){
		    result = res.data;
			if(result.length>0){
				getArea(result[0]['rowid'],"J_cdistrict");
				for (var i = 0; i < result.length; i++) {
			       	var shtml = '<option value="'+result[i].areaname+'"   data-id ="'+result[i].rowid+'">'+result[i].areaname+'</option>';
			       	$("#"+id).append(shtml);
			    }
			}
		}
		});
	}

	function upload(data,id,name){
		$.ajax({
		 url:"{:url('User/ajaxuploads')}",
		 type:'POST',
		 data:data,
		 cache: false,
		 contentType: false,    //不可缺
		 processData: false,    //不可缺
		 success:function(data){
			 var res = JSON.parse(data);
			 html = "";
			 if(res.status == 1){
				 html = "<a  class='liLabel' onclick='delpic("+id+")' num_id = '"+id+"' title='点击图片即可删除对应的细节图片'  ><img src='"+res.path+"'  height='50px;' style='margin-left:10px;'> <input class='infile' name='"+name+"' type='text' value='"+res.path+"' ></a>";
				 $('#minpic'+id).append(html);
			 }else{
	 			alert('参数错误！');
	 			oBtn1.disabled = false;
			 }
		 }
		});
	}

	//删除图片
	function delpic(id){
		var flag = confirm("确定删除吗?");
		if(!flag){
		  return false;
		}
		$('[num_id='+id+']').remove();
	}
</script>



</body>


</body>
</html>
